/**
 * Created by george on 16/4/9.
 */
//require("babel-polyfill");

/**
 * core framework dependencies
 */
var React = require('react');
var ReactDOM = require('react-dom');
var ReactCSSTransitionGroup = require('react-addons-css-transition-group');
var ReactRouter = require('react-router');
var hashHistory = ReactRouter.hashHistory,
    Router = ReactRouter.Router,
    Route = ReactRouter.Route;
    //IndexRoute = ReactRouter.IndexRoute,
    //Link = ReactRouter.Link;

//import React from 'react';
//import {render} from 'react-dom';
//import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
//import {hashHistory, Router, Route, IndexRoute, Link} from 'react-router';

/**
 * import views
 */
var Index = require('./view/index/index');
//import Index from './view/index/index'

/**
 * import layouts
 */
var Header = require('./layout/header/header');
//import Header from './layout/header/header'

/**
 * define app
 */
var AppPointer = "";

//const App = React.createClass({
//  getInitialState() {
//    return {
//      hello: true
//    }
//  },
//  componentDidMount() {
//    //var path = this.props.location.pathname;
//    AppPointer = this;
//  },
//  render() {
//    return (
//      <div id="main">
//        <Header ref="header" parentPointer={this}/>
//        <ReactCSSTransitionGroup
//          component="div"
//          transitionName="fade"
//          transitionEnterTimeout={200}
//          transitionLeave={false}
//          transitionLeaveTimeout={200}
//        >
//          {React.cloneElement(this.props.children, {
//            key: this.props.location.pathname,
//            parentPointer: this
//          })}
//        </ReactCSSTransitionGroup>
//      </div>
//    )
//  }
//});

//ReactDOM.render((
//  <Router history={hashHistory}>
//    <Route path="/" component={App}>
//      <IndexRoute component={Index}/>
//      {/*<Route path="Welcome" component={Welcome}/>*/}
//    </Route>
//  </Router>
//), document.getElementById('container'));

ReactDOM.render(<Header />, document.getElementById('container'));

/**
 * FASTCLICK (OPTIMIZE TOUCH EXPERIENCE)
 */
var FastClick = require('fastclick');
if ('addEventListener' in document) {
  document.addEventListener('DOMContentLoaded', function () {
    FastClick.attach(document.body);
  }, false);
}

/**
 * FORMAT DATE
 * @param fmt Date
 * @return format String
 */
Date.prototype.Format = function (fmt) {
  var o = {
    "M+": this.getMonth() + 1, // 月份
    "d+": this.getDate(), // 日
    "h+": this.getHours(), // 小时
    "m+": this.getMinutes(), // 分
    "s+": this.getSeconds(), // 秒
    "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
    "S": this.getMilliseconds() // 毫秒
  };
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(String(o[k]).length)));
    }
  }
  return fmt;
};
